package cn.bx.bid.ctrl;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RoleInterceptor extends HandlerInterceptorAdapter {
    //请求之前，return true:继续执行；return false
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
      //  return super.preHandle(request, response, handler);
      /*  long start=System.nanoTime();
        request.setAttribute("s",start);*/
      /*if(request.getSession().getAttribute("USER_LOGIN")==null){
          request.setAttribute("msg","没有权限访问");
          request.getRequestDispatcher("/login.jsp").forward(request,response);
          return false;
      }*/
        return true;

    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
      //  super.postHandle(request, response, handler, modelAndView);
      /*  long end=System.nanoTime();
        request.setAttribute("e",end);*/
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
       // super.afterCompletion(request, response, handler, ex);
      /*  long start=(long)request.getAttribute("s");
        long end=(long)request.getAttribute("e");
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+(end-start));*/

    }
}
